package com.lagou.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class MyMessageListener {

    @RabbitListener(queues = "MyDeadQueue")
    public void onMessage(Channel channel, Message message) {
        System.out.println("消息接收时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        System.out.println("channel:" + channel + ",thread:" + Thread.currentThread().getName() + ",message:" + new String(message.getBody()));
    }
}
